include_directories(${GSTREAMER_INCLUDE_DIRS} ${GSTREAMER_PBUTILS_INCLUDE_DIR} ${GLIB2_INCLUDE_DIR} ${QTGSTREAMER_INCLUDES})
add_definitions(${QTGSTREAMER_DEFINITIONS} -DGST_DISABLE_XML -DGST_DISABLE_LOADSAVE)
add_definitions(-DSRCDIR="${CMAKE_CURRENT_SOURCE_DIR}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${QTGSTREAMER_FLAGS}")

macro(qgst_test target)
    add_executable(${target} "${target}.cpp")
    target_link_libraries(${target} ${GSTREAMER_LIBRARY} ${GOBJECT_LIBRARIES}
                                    ${QTGSTREAMER_LIBRARIES}
                                    ${GSTREAMER_PBUTILS_LIBRARY})
    qt4or5_use_modules(${target} Test)
    add_test(NAME ${target} COMMAND ${target})
endmacro(qgst_test)

qgst_test(refpointertest)
qgst_test(propertiestest)
qgst_test(signalstest)
qgst_test(valuetest)
qgst_test(structuretest)
qgst_test(capstest)
qgst_test(childproxytest)
qgst_test(structstest)
qgst_test(parsetest)
qgst_test(urihandlertest)
qgst_test(bustest)
qgst_test(querytest)
qgst_test(clocktest)
qgst_test(buffertest)
qgst_test(eventtest)
qgst_test(messagetest)
qgst_test(taglisttest)
qgst_test(discoverertest)
qgst_test(allocatortest)
qgst_test(memorytest)
qgst_test(padtest)

if(TARGET Qt5GStreamerQuick)
    add_executable(qtquick2test qtquick2test.cpp)
    target_link_libraries(qtquick2test Qt5::Qml Qt5GStreamerQuick ${QTGSTREAMER_LIBRARIES})
    qt4or5_use_modules(qtquick2test Test)
    add_test(NAME qtquick2test
             COMMAND cmake -E env QML2_IMPORT_PATH=${CMAKE_BINARY_DIR}/src/qml/quick2/:$ENV{QML2_IMPORT_PATH} GST_PLUGIN_PATH=${CMAKE_BINARY_DIR}/elements/gstqtvideosink/:$ENV{GST_PLUGIN_PATH} ${CMAKE_CURRENT_BINARY_DIR}/qtquick2test
             WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endif()
